package cn.swust.designpatternlearningplatform.service.impl;

import cn.swust.designpatternlearningplatform.dao.*;
import cn.swust.designpatternlearningplatform.domain.bo.ContentBo;
import cn.swust.designpatternlearningplatform.domain.bo.OptionsBo;
import cn.swust.designpatternlearningplatform.domain.bo.TrainingTopicBo;
import cn.swust.designpatternlearningplatform.domain.dto.ShowStudentDto;
import cn.swust.designpatternlearningplatform.domain.dto.StudentPersonalTrainingResultDto;
import cn.swust.designpatternlearningplatform.domain.dto.TeacherPaperListDto;
import cn.swust.designpatternlearningplatform.domain.dto.TestPaperDto;
import cn.swust.designpatternlearningplatform.domain.entity.PaperResult;
import cn.swust.designpatternlearningplatform.domain.entity.Student;
import cn.swust.designpatternlearningplatform.domain.entity.TestPaper;
import cn.swust.designpatternlearningplatform.domain.entity.Topic;
import cn.swust.designpatternlearningplatform.domain.vo.TestPaperVo;
import cn.swust.designpatternlearningplatform.domain.vo.UpdateTestPaperTopic;
import cn.swust.designpatternlearningplatform.service.TeacherTestService;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;

@Service
@Transactional
public class TeacherTestServiceImpl implements TeacherTestService {
    @Resource
    private StudentTrainingPaperDao studentTrainingPaperDao;
    @Resource
    private TeacherTestDao teacherTestDao;
    @Resource
    private TeacherDao teacherDao;
    @Resource
    private PaperResultDao paperResultDao;
    @Resource
    private ObtainResultsDao obtainResultsDao;
    @Resource
    private StudentDao studentDao;
    @Resource
    private TestPaperDao testPaperDao;
    @Resource
    private TestPaperContentDao testPaperContentDao;
    @Resource
    private TopicKnowledgePointDao topicKnowledgePointDao;
    @Resource
    private TopicKnowledgeCorrelationDao topicKnowledgeCorrelationDao;
    @Resource
    private TopicDao topicDao;
    @Resource
    private TopicOptionDao topicOptionDao;

    /**
     * @param semester:
     * @param teacherNumber:
     * @return List<TeacherPaperListDto>
     * @author wang
     * description 通过老师的账号以及学期问题进行一个分组，返回当下的学期发布和待发布的试卷
     * date 2023/5/19 12:25
     */
    @Override
    public List<TeacherPaperListDto> getPaperListBySemester(String semester, String teacherNumber) {
        List<TestPaper> testPaper = teacherTestDao.getPaperListBySemester(semester, teacherNumber);
        List<TeacherPaperListDto> list = new ArrayList<>();
        int a[] = new int[testPaper.size()];
        for (int i = 0; i < testPaper.size(); i++) {
            if (a[i] == 0) {
                List<String> classNumber = new ArrayList<>();
                TeacherPaperListDto teacherPaperListDto = new TeacherPaperListDto();
                classNumber.add(testPaper.get(i).getClassNumber());
                a[i] = 1;
                for (int j = i + 1; j < testPaper.size(); j++) {
                    if (testPaper.get(i).getPaperNumber().equals(testPaper.get(j).getPaperNumber())) {
                        a[j] = 1;
                        classNumber.add(testPaper.get(j).getClassNumber());
                    }
                }
                teacherPaperListDto.setSemester(semester);
                teacherPaperListDto.setId(testPaper.get(i).getPaperNumber());
                teacherPaperListDto.setPublisher(teacherDao.getTeacherByNumber(testPaper.get(i).getTeacherNumber()).getTeacherName());
                teacherPaperListDto.setIsPublish(testPaper.get(i).getIsPublish().equals("是"));
                teacherPaperListDto.setEndTime(String.valueOf(testPaper.get(i).getEndTime()));
                teacherPaperListDto.setProblemNum(testPaper.get(i).getTopicNumber());
                teacherPaperListDto.setTitle(testPaper.get(i).getTestName());
                teacherPaperListDto.setPublishTime(String.valueOf(testPaper.get(i).getPublishTime()));
                teacherPaperListDto.setTestTime(testPaper.get(i).getDoableTime());
                teacherPaperListDto.setStartTime(String.valueOf(testPaper.get(i).getStartTime()));
                teacherPaperListDto.setClassArray(classNumber);
                Set<String> studentNumber = teacherTestDao.getCompeleteStudent(testPaper.get(i).getPaperNumber());
                teacherPaperListDto.setCompleteStudentNumber(studentNumber.size());
                list.add(teacherPaperListDto);
            }
        }
        Arrays.fill(a, 0);
        return list;
    }

    /**
     * @param teacherNumber:
     * @return List<TeacherPaperListDto>
     * @author wang
     * description 通过老师的账号查找对应老师下的发布的试卷，（包含已经发布和没有发布保存为草稿的试卷）已发布且已经可以开始做了的不能修改题目内容，只能删除重新发布
     * date 2023/5/19 12:17
     */

    @Override
    public List<TeacherPaperListDto> getPaperList(String teacherNumber) {
        List<TestPaper> testPaper = teacherTestDao.getPaperList(teacherNumber);
        List<TeacherPaperListDto> list = new ArrayList<>();
        //通过学期进行分组
        Map<String, List<TestPaper>> collect = testPaper.stream().collect(Collectors.groupingBy(TestPaper::getSemester));
        System.out.println(collect);
        for (Map.Entry<String, List<TestPaper>> entry : collect.entrySet()) {
            String semester = entry.getKey();
            List<TestPaper> testPapers = entry.getValue();
            int a[] = new int[testPapers.size()];
            for (int i = 0; i < testPapers.size(); i++) {
                if (a[i] == 0) {
                    List<String> classNumber = new ArrayList<>();
                    TeacherPaperListDto teacherPaperListDto = new TeacherPaperListDto();
                    classNumber.add(testPapers.get(i).getClassNumber());
                    a[i] = 1;
                    for (int j = i + 1; j < testPapers.size(); j++) {
                        if (testPapers.get(i).getPaperNumber().equals(testPapers.get(j).getPaperNumber())) {
                            a[j] = 1;
                            classNumber.add(testPapers.get(j).getClassNumber());
                        }
                    }
                    teacherPaperListDto.setSemester(semester);
                    teacherPaperListDto.setId(testPapers.get(i).getPaperNumber());
                    teacherPaperListDto.setPublisher(teacherDao.getTeacherByNumber(testPapers.get(i).getTeacherNumber()).getTeacherName());
                    teacherPaperListDto.setIsPublish(testPapers.get(i).getIsPublish().equals("是"));
                    teacherPaperListDto.setEndTime(String.valueOf(testPapers.get(i).getEndTime()));
                    teacherPaperListDto.setProblemNum(testPapers.get(i).getTopicNumber());
                    teacherPaperListDto.setTitle(testPapers.get(i).getTestName());
                    teacherPaperListDto.setPublishTime(String.valueOf(testPapers.get(i).getPublishTime()));
                    teacherPaperListDto.setTestTime(testPapers.get(i).getDoableTime());
                    teacherPaperListDto.setStartTime(String.valueOf(testPapers.get(i).getStartTime()));
                    teacherPaperListDto.setClassArray(classNumber);
                    Set<String> studentNumber = teacherTestDao.getCompeleteStudent(testPapers.get(i).getPaperNumber());
                    teacherPaperListDto.setCompleteStudentNumber(studentNumber.size());
                    list.add(teacherPaperListDto);
                }
            }
            Arrays.fill(a, 0);
        }
        return list;
    }

    /**
     * @param testId:
     * @return MultipartFile
     * @author wang
     * description 导出学生的成绩具体到每个小题的分数，学生的个人信息为：学号，姓名，班级，
     * date 2023/5/19 16:38
     */
    @Override
    public XSSFWorkbook getStudentScore(String testId) {
        XSSFWorkbook workbook = new XSSFWorkbook();
        List<PaperResult> paperResult = paperResultDao.getPaperResultByTestId(testId);
        Map<Integer, Integer> topicScore = new HashMap<>();
        int flag = 0;
        Map<String, List<PaperResult>> collect = paperResult.stream().collect(Collectors.groupingBy(PaperResult::getStudentNumber));
        // 创建一个工作表
        XSSFSheet sheet = workbook.createSheet("Sheet1");
        // 创建表头
        XSSFRow headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("姓名");
        headerRow.createCell(1).setCellValue("学号");
        headerRow.createCell(2).setCellValue("班级");
        int count = 1;
        for (Map.Entry<String, List<PaperResult>> entry : collect.entrySet()) {
            List<PaperResult> list = entry.getValue();
            List<PaperResult> collect1 = list.stream().sorted(Comparator.comparingInt(PaperResult::getTopicId)).collect(Collectors.toList());
            if (flag == 0) {
                int cnt = 3;
                for (int i = 0; i < collect1.size(); i++) {
                    Integer topicId = collect1.get(i).getTopicId();
                    Integer score = obtainResultsDao.getScore(collect1.get(i).getPaperNumber(), topicId);
                    topicScore.put(topicId, score);
                    String s = "第" + (i + 1) + "题";
                    headerRow.createCell(cnt).setCellValue(s);
                    cnt++;
                }
                headerRow.createCell(cnt).setCellValue("总分");
                flag = 1;
            }
            XSSFRow data = sheet.createRow(count);
            Student student = new Student();
            student = studentDao.getStudentByNumber(entry.getKey());
            data.createCell(0).setCellValue(student.getStudentName());
            data.createCell(1).setCellValue(student.getStudentNumber());
            data.createCell(2).setCellValue(student.getClassNumber());
            int cnt = 3;
            int sum = 0;
            for (int i = 0; i < collect1.size(); i++) {
                if (collect1.get(i).getIsRight() == 0) {
                    data.createCell(cnt).setCellValue(0);
                } else {
                    data.createCell(cnt).setCellValue(topicScore.get(collect1.get(i).getTopicId()));
                    sum = sum + topicScore.get(collect1.get(i).getTopicId());
                }
                cnt++;
            }
            data.createCell(cnt).setCellValue(sum);
            count++;
        }
        return workbook;
    }

    @Override
    public String deleteTestList(String testId) {
        paperResultDao.deleteResult(testId);
        testPaperDao.deleteTestPaper(testId);
        testPaperContentDao.deleteTestPaperContent(testId);
        return "删除成功";
    }

    @Override
    public String addTestPaper(TestPaperVo testPaperVo, String teacherNumber) {
        //组卷的依据
        List<ContentBo> list = testPaperVo.getContent();
        Map<String, List<Integer>> map = new HashMap<>();
        int flag = 0;
        String msg = null;
        Integer sum = 0;
        for (int i = 0; i < list.size(); i++) {
            ContentBo contentBo = list.get(i);
            Integer pointId = topicKnowledgePointDao.selectPointIdByContent(contentBo.getTopicKnowledge());
            List<Integer> list1 = topicKnowledgeCorrelationDao.getPointLinkedWithTopic(pointId);
            Set set1 = new HashSet<>(list1);
            List<Integer> topicId = new ArrayList<>(set1);

            if (topicId.size() < contentBo.getTopicNumber()) {
                flag = 1;
                msg = contentBo.getTopicKnowledge();
                break;
            } else {
                Set<Integer> set = new HashSet<>();
                if (contentBo.getTopicNumber() == topicId.size()) {
                    map.put(contentBo.getTopicKnowledge(), topicId);
                    sum = sum + topicId.size();
                } else {
                    while (set.size() < contentBo.getTopicNumber()) {
                        set.add(topicId.get(ThreadLocalRandom.current().nextInt(0, topicId.size() - 1)));
                    }
                    List<Integer> list2 = new ArrayList<>(set);
                    sum = sum + list2.size();
                    map.put(contentBo.getTopicKnowledge(), list2);
                }

            }
        }
        if (flag == 1) {
            msg = msg + "类型的题目数量不足，请重新选择！";
            return msg;
        } else {

            List<String> classNumber = testPaperVo.getClassNumber();
            String uuid = UUID.randomUUID().toString();
            TestPaper testPaper = new TestPaper();
            testPaper.setTopicNumber(sum);
            testPaper.setTestScore(100);
            testPaper.setPaperNumber(uuid);
            testPaper.setTestName(testPaperVo.getTestName());
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            LocalDateTime dateTime = LocalDateTime.parse(testPaperVo.getStartTime(), formatter);
            LocalDateTime dateTime1 = LocalDateTime.parse(testPaperVo.getEndTime(), formatter);
            testPaper.setStartTime(dateTime);
            testPaper.setEndTime(dateTime1);
            testPaper.setDoableTime(testPaperVo.getDoableTime());

            if (testPaperVo.getIsPublish()) {
                testPaper.setIsPublish("是");
                LocalDateTime time = LocalDateTime.now();
                testPaper.setPublishTime(time);
            } else {
                testPaper.setIsPublish("否");
            }
            testPaper.setTeacherNumber(teacherNumber);
            testPaper.setSemester(testPaperVo.getSemester());
            for (int i = 0; i < classNumber.size(); i++) {
                TestPaper testPaper1 = new TestPaper();
                BeanUtils.copyProperties(testPaper, testPaper1);
                testPaper1.setClassNumber(classNumber.get(i));
                testPaperDao.addTestPaper(testPaper1);
            }
            for (Map.Entry<String, List<Integer>> entry : map.entrySet()) {
                List<Integer> list1 = entry.getValue();
                BigDecimal num1 = new BigDecimal(100);
                BigDecimal num2 = new BigDecimal(testPaper.getTopicNumber());
                System.out.println(num1);
                System.out.println("$$$$$$$$$$$$$$$$$$$$$");
                System.out.println(num2);
                BigDecimal result = num1.divide(num2, 2, RoundingMode.DOWN);
                for (int i = 0; i < list1.size(); i++) {
                    testPaperContentDao.addTestPaper(list1.get(i), testPaper.getPaperNumber(), result.toString());
                }
            }
            return "添加成功";
        }

    }

    /**
     * @param testId:
     * @return TestPaperDto
     * @author wang
     * description 查看组的试卷的详细信息
     * date 2023/5/28 16:03
     */
    @Override
    public TestPaperDto selectTestPaper(String testId, String number) {
        TestPaperDto testPaperDto = new TestPaperDto();
        List<TrainingTopicBo> trainingTopicBoList = new ArrayList<>();
        List<Integer> topicId = testPaperContentDao.selecteTestPaper(testId);
        List<PaperResult> results = new ArrayList<>();
        if (!number.isEmpty()) {
            results = paperResultDao.getPaperResult(number, testId);
        }
        if (!results.isEmpty()) {
            return null;
        }
        for (int i = 0; i < topicId.size(); i++) {
            Topic topic = topicDao.selectTopicById(topicId.get(i));
            List<OptionsBo> list3 = topicOptionDao.getTopicOptions(topic.getTopicId());
            TrainingTopicBo trainingTopicBo = new TrainingTopicBo();
            trainingTopicBo.setTopicId(topic.getTopicId());
            trainingTopicBo.setTopicType(topic.getTopicType());
            trainingTopicBo.setTopicDifficulty(topic.getTopicDifficulty());
            trainingTopicBo.setTopicContent(topic.getTopicContent());
            trainingTopicBo.setTopicContentPath(topic.getTopicContentPath());
            trainingTopicBo.setOptions(list3);
            trainingTopicBoList.add(trainingTopicBo);
        }
        testPaperDto.setPaperNumber(testId);
        testPaperDto.setTrainingTopicBoList(trainingTopicBoList);
        return testPaperDto;
//        TestPaperDto testPaperDto=new TestPaperDto();
//        List<TrainingTopicBo> trainingTopicBoList=new ArrayList<>();
//        List<Integer> topicId=testPaperContentDao.selecteTestPaper(testId);
//        List<PaperResult> results=new ArrayList<>();
//        results=paperResultDao.getPaperResultByTestId(testId);
//        if (!number.isEmpty())
//        {
//            results=paperResultDao.getPaperResult(number,testId);
//            //results=paperResultDao.getPaperResultByTestId(testId);
//        }
//        if (results!=null)
//        {
//            return null;
//        }
//        for (int i = 0; i < topicId.size(); i++) {
//            Topic topic=topicDao.selectTopicById(topicId.get(i));
//            List<OptionsBo> list3=topicOptionDao.getTopicOptions(topic.getTopicId());
//            TrainingTopicBo trainingTopicBo=new TrainingTopicBo();
//            trainingTopicBo.setTopicId(topic.getTopicId());
//            trainingTopicBo.setTopicType(topic.getTopicType());
//            trainingTopicBo.setTopicDifficulty(topic.getTopicDifficulty());
//            trainingTopicBo.setTopicContent(topic.getTopicContent());
//            trainingTopicBo.setTopicContentPath(topic.getTopicContentPath());
//            trainingTopicBo.setOptions(list3);
//            trainingTopicBoList.add(trainingTopicBo);
//        }
//        testPaperDto.setPaperNumber(testId);
//        testPaperDto.setTrainingTopicBoList(trainingTopicBoList);
//        return testPaperDto;
    }

    /**
     * @param updateTestPaperTopic:
     * @return TrainingTopicBo
     * @author wang
     * description 根据题目的知识点进行同类型换题的操作
     * date 2023/5/28 15:59
     */
    @Override
    public Object updateTestPaperTopic(UpdateTestPaperTopic updateTestPaperTopic) {
        List<Integer> pointId = topicKnowledgeCorrelationDao.getPointIdByTopicId(updateTestPaperTopic.getTopicId());
        Set<Integer> topicId = new HashSet<>();
        for (int i = 0; i < pointId.size(); i++) {
            List<Integer> set = topicKnowledgeCorrelationDao.getPointLinkedWithTopic(pointId.get(i));
            topicId.addAll(set);
        }
        List<Integer> list = new ArrayList<>(topicId);
        List<Integer> list1 = testPaperContentDao.selecteTestPaper(updateTestPaperTopic.getPaperNumber());
        List<Integer> list2 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (!list1.contains(list.get(i))) {
                list2.add(list.get(i));
            }
        }
        if (list2.isEmpty()) {
            return "该类型下没有可以替换的题目";
        } else {
            Integer newTopicId = list.get(ThreadLocalRandom.current().nextInt(0, list.size() - 1));
            testPaperContentDao.updateTestPaperTopic(updateTestPaperTopic.getPaperNumber(), updateTestPaperTopic.getTopicId(), newTopicId);
            Topic topic = topicDao.selectTopicById(newTopicId);
            List<OptionsBo> list3 = topicOptionDao.getTopicOptions(newTopicId);
            TrainingTopicBo trainingTopicBo = new TrainingTopicBo();
            trainingTopicBo.setTopicId(topic.getTopicId());
            trainingTopicBo.setTopicType(topic.getTopicType());
            trainingTopicBo.setTopicDifficulty(topic.getTopicDifficulty());
            trainingTopicBo.setTopicContent(topic.getTopicContent());
            trainingTopicBo.setTopicContentPath(topic.getTopicContentPath());
            trainingTopicBo.setOptions(list3);
            return trainingTopicBo;
        }
    }

    /**
     * @param testId:
     * @return String
     * @author wang
     * description 获取试卷的姓名
     * date 2023/6/1 17:46
     */
    @Override
    public String getPaperName(String testId) {
        Set<String> paperName = testPaperDao.getPaperName(testId);
        List<String> paperName1 = new ArrayList<>(paperName);
        String paperName2 = null;
        for (int i = 0; i < paperName1.size(); i++) {
            paperName2 = paperName1.get(i);
            break;
        }
        return paperName2;
    }

    /**
     * @param testId:
     * @return Set<String>
     * @author wang
     * description 通过试卷id来获取当前试卷做了的人
     * date 2023/6/1 17:47
     */
    @Override
    public Set<String> getStudentNumber(String testId) {
        Set<String> studentNumber = paperResultDao.getStudentNumber(testId);
        return studentNumber;
    }

    /**
     * @param testId:
     * @param studentNumber:
     * @return List<StudentPersonalTrainingResultDto>
     * @author wang
     * description 返回试卷
     * date 2023/6/1 17:48
     */
    @Override
    public List<StudentPersonalTrainingResultDto> getStudentPersonalTraining(String testId, String studentNumber) {
        List<Integer> topicId = paperResultDao.getTopicId(testId, studentNumber);
        List<StudentPersonalTrainingResultDto> studentPersonalTrainingResultDtos = new ArrayList<>();
        for (int i = 0; i < topicId.size(); i++) {
            Topic topic = topicDao.selectTopicById(topicId.get(i));
            List<OptionsBo> options = topicOptionDao.getTopicOptions(topicId.get(i));
            StudentPersonalTrainingResultDto s = new StudentPersonalTrainingResultDto();
            s.setTopicContent(topic.getTopicContent());
            s.setTopicContentPath(topic.getTopicContentPath());
            s.setOptions(options);
            s.setTopicAnalyse(topic.getTopicAnalyse());
            s.setTopicAnalysePath(topic.getTopicAnalysePath());
            s.setRightAnswer(topic.getTopicAnswer());
            String ownAnswer = studentTrainingPaperDao.getOwnAnswer(testId, topicId.get(i), studentNumber);
            s.setOwnAnswer(ownAnswer);
            studentPersonalTrainingResultDtos.add(s);
        }
        return studentPersonalTrainingResultDtos;
    }

    @Override
    public List<ShowStudentDto> getStudentTest(String paperId, String classId, String semester) {
        List<PaperResult> results = paperResultDao.getPaperResultByTestId(paperId);
        Map<String, List<PaperResult>> collect = results.stream().collect(Collectors.groupingBy(PaperResult::getStudentNumber));
        List<ShowStudentDto> showStudentDto = new ArrayList<>();

        for (Map.Entry<String, List<PaperResult>> entry : collect.entrySet()) {
            List<PaperResult> list = entry.getValue();
            int simpleRight = 0;//简单题的正确数量
            int simpleWrong = 0;//简单题的错题数量
            int middleRight = 0;//中等题的正确数量
            int middleWrong = 0;//中等题的错误数量
            int difficultRight = 0;//困难题目的正确数量
            int difficultWrong = 0;//困难题目的错误数量
            int normalRight = 0;//没有题目难度的正确的数量
            int normalWrong = 0;//没有题目难度的错误的数量
            ShowStudentDto studentDto = new ShowStudentDto();
            int sum = 0;//总分
            for (int i = 0; i < list.size(); i++) {
                PaperResult paperResult = list.get(i);
                String topicDifficult = topicDao.getTopicDifficultyById(paperResult.getTopicId());
                int sorce = 0;
                if (paperResult.getIsRight() == 1) {
                    sorce = obtainResultsDao.getScore(paperId, paperResult.getTopicId());
                    sum = sum + sorce;
                }
                if (topicDifficult == null) {
                    if (paperResult.getIsRight() == 1) {
                        normalRight++;
                    } else {
                        normalWrong++;
                    }
                } else {
                    if (topicDifficult.equals("简单")) {
                        if (paperResult.getIsRight() == 1) {
                            simpleRight++;
                        } else {
                            simpleWrong++;
                        }
                    } else if (topicDifficult.equals("中等")) {
                        if (paperResult.getIsRight() == 1) {
                            middleRight++;
                        } else {
                            middleWrong++;
                        }
                    } else {
                        if (paperResult.getIsRight() == 1) {
                            difficultRight++;

                        } else {
                            difficultWrong++;
                        }
                    }
                }
            }
            studentDto.setStudentNumber(entry.getKey());
            studentDto.setStudentName(studentDao.getStudentName(entry.getKey()));
            studentDto.setSorce(sum);
            studentDto.setSimpleRight(simpleRight);
            studentDto.setSimpleWrong(simpleWrong);
            studentDto.setMiddleRight(middleRight);
            studentDto.setMiddleWrong(middleWrong);
            studentDto.setDifficultRight(difficultRight);
            studentDto.setDifficultWrong(difficultWrong);
            studentDto.setNormalRight(normalRight);
            studentDto.setNormalWrong(normalWrong);
            showStudentDto.add(studentDto);

            list.clear();
        }
        return showStudentDto;
    }

    @Override
    public String publishTestPaper(String paperId) {
        String s = "是";
        LocalDateTime time = LocalDateTime.now();
        teacherTestDao.updatePaperPublishState(s, paperId, time);
        return "发布成功";
    }
}
